package com.itcast.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author tyy
 * @Description TODO
 * @Since 2022/1/31
 */
@Controller
@RequestMapping("test")// 可以去掉
public class TestController {
    @ResponseBody
    @RequestMapping("test")
    public String test() {
        // 测试死循环
         // 测试内存溢出
//        boolean flag = true;
//        while (flag){
//            System.out.println("dead--------------");
//        }
        return "test===Hello World！！！";
    }
    @ResponseBody
    @GetMapping("{id}")
    public String getOne(@PathVariable String id) {
        return DATA_MAP.get(id);
    }

    private final static Map<String, String> DATA_MAP = new HashMap() {
        {
            put("1", "aaa");
            put("2", "bbb");
            put("3", "ccc");
        }
    };
}
